package com.xiaoxian.basic.cotroller;

import com.xiaoxian.basic.domain.dto.SmsCode;
import com.xiaoxian.basic.service.IVerifyCodeImgService;
import com.xiaoxian.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verify_code")
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeImgService verifyCodeImgService;

    /**
     * 图像验证码
     * @param imageCodeKey
     * @return
     */
    @GetMapping("/image/{imageCodeKey}")
    public AjaxResult verifyCodeImg(@PathVariable(value = "imageCodeKey") String imageCodeKey){
        return verifyCodeImgService.verifyCodeImg(imageCodeKey);
    }

    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody @Valid SmsCode smsCode){
        return verifyCodeImgService.sendSmsCode(smsCode);
    }
}
